import request from '@/utils/request'

// 登录
export function login(data) {
  return request({
    url: '/admin/login',
    method: 'get',
    params: data
  })
}
// 获取token
export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: { token }
  })
}

// 登出
export function logout() {
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
}

// 注册
export function register(adminInfo) {
  // /admin/register
  return request({
    url: "/admin/register",
    method: "post",
    params: adminInfo
  })
}

// 查询所有管理员
export function getadminsInfo() {
  return request({
    url: '/admin',
    method: 'get',
  })
}
// 新增管理员
export function postadminsInfo(adminInfo) {
  console.log(adminInfo, "adminInfo");
  return request({
    url: '/admin',
    method: 'POST',
    data: adminInfo
  })
}
// 根据id查询管理员
export function getidadminInfo(id) {
  return request({
    url: `/admin/${id}`,
    method: 'get',
  })
}
// 增加管理员
export function postadminInfo() {
  return request({
    url: '/admin',
    method: 'post',
  })
}
// 修改管理员
export function putadminInfo(item) {
  return request({
    url: `/admin/${item._id}`,
    method: 'put',
    params: { _id: id },
    data: item,
  })
}
// 删除管理员
export function deleteadminInfo(id) {
  return request({
    url: `/admin/:id`,
    method: 'delete',
    params: { _id: id }
  })
}

